package com.example.main;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.util.DisplayMetrics;
import android.view.MotionEvent;
import android.view.View;

public class Buttons extends View{

	Bitmap bBtnHit;
	PlayCards c_PlayCards;
	enum State{
		eStateBegin,
		eStateBet,
		eStateDeal,
		
	};

	State eState;
	
	int width = 0;
	int height = 0;
	int bButtonHit_H = 0;
	int bButtonHit_W = 0;
	boolean bDealTrue = true;
	
	public Buttons(Context context) {
		super(context);
		DisplayMetrics metrics = context.getResources().getDisplayMetrics();
		width = metrics.widthPixels;
		height = metrics.heightPixels;
		bBtnHit = BitmapFactory.decodeResource(getResources(), R.drawable.btn_hit);
		bButtonHit_H = bBtnHit.getHeight();
		bButtonHit_W = bBtnHit.getWidth();

		
		// TODO Auto-generated constructor stub
	}

	@Override
	public void draw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.draw(canvas);
		if (bDealTrue){
			canvas.drawBitmap(bBtnHit, (width/2)-(bButtonHit_W/2), height-bButtonHit_H, null);
		}
		
		Paint paint = new Paint();
		paint.setColor(Color.WHITE);
		paint.setStyle(Style.FILL);
		paint.setTextSize(40);
		//canvas.drawText("ihuuuuuuuu", 10, 40, paint);
		
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		// TODO Auto-generated method stub

		int action = event.getAction();
		float x = event.getX();  // or getRawX();
		float y = event.getY();


		if (x >= (width/2)-(bButtonHit_W/2) && x < ((width/2)-(bButtonHit_W/2) + bBtnHit.getWidth())
				&& y >= height-bButtonHit_H && y < (height-bButtonHit_H + bBtnHit.getHeight())) {
			bDealTrue = false;
			c_PlayCards.GetPlayerCards();
		}



		invalidate();
		return true;

	}
	
	

}
